package com.game.gameshoppingcenter.controller;


import com.game.gameshoppingcenter.entities.User;
import com.game.gameshoppingcenter.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("")
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping("/usertoLogin")
    public String tologin(Model model){

        return "Login/login";
    }
    @RequestMapping("/userlogin")
    public String login(Model model){


        return  "Home/home";
    }
    @RequestMapping("/usertoRegister")
    public String toRegister(Model model){
        User user =new User();
        model.addAttribute("user",user);
        return "Register/register";
    }
    @RequestMapping("/userregister")
    public String register(){
        return  "Login/login";
    }
    @PostMapping("/save")
    public String createAdmin (Model model, User user){
             userService.save(user);
             return "redirect:register";
    }
}
